"""
需求：爬取郑州经贸官网所有的图片
url = 'https://www.zueb.edu.cn/'
"""
import requests
import re

url = 'https://www.zueb.edu.cn/'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}
res = requests.get(url, headers=headers)
html = res.content.decode()

pat = re.compile(r'[^\s]*?\.jpg')
imgList = re.findall(pat, html)
print(imgList)
i = 1
for img in imgList:
    href = url + img.lstrip('src="')
    print(href)
    res = requests.get(href)
    with open(str(i) + ".jpg", "wb") as fp:
        fp.write(res.content)
        i += 1